<template>
  <el-dialog title="备注记录" :visible.sync="dialogVisible">
    <el-table :data="tableData" border>
      <el-table-column label="备注记录" prop="operator_content" />
      <el-table-column label="操作人员" prop="operator" width="200" />
      <el-table-column label="时间" prop="create_time" width="200" />
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">关闭</el-button>
      <el-button type="primary" @click="addNotes">添加备注</el-button>
    </div>

    <el-dialog
      width="30%"
      title="添加备注"
      :visible.sync="innerVisible"
      append-to-body>
      <el-form :model="form">
        <el-form-item label="备注：" :label-width="formLabelWidth">
          <el-input
            type="textarea"
            v-model="form.content"
            autocomplete="off"
            :rows="3"
            placeholder="请输入备注内容"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="submit">确定</el-button>
      </div>
    </el-dialog>
  </el-dialog>
</template>

<script>
import { remarksRecord, addRemarks } from "@/api/complaint";
export default {
  props: ["suggestId"],
  data() {
    return {
      tableData: [],
      dialogVisible: false,
      innerVisible: false,
      formLabelWidth: "120px",
      form: {
        content: "",
      },
    };
  },
  methods: {
    close() {
      this.dialogVisible = false;
      this.innerVisible = false;
      this.form.content = ''
    },
    addNotes() {
      this.dialogVisible = false;
      this.innerVisible = true;
    },
    getData(){
    },
    submit(){
      if (!this.form.content) {
        this.$message.warning("请输入备注信息");
        return false;
      }
      addRemarks({
        suggest_id: this.suggestId,
        content: this.form.content
      }).then(res =>{
        this.close()
        this.$parent.getList();
      })
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        remarksRecord(this.suggestId).then(res =>{
          this.tableData = res
        })
      }
    }
  },
  mounted() {
    this.getData()
  },
};
</script>

<style lang="scss" scoped>
</style>